package com.nervenets.web.controller.handler.user.wealth;

import com.nervenets.web.controller.handler.Handler;
import com.nervenets.web.controller.handler.common.TokenParams;
import com.nervenets.web.hibernate.domain.user.Bank;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

public class UserBanksHandler extends Handler<TokenParams> {
    @Override
    public String handle(TokenParams params, HttpServletRequest request) throws Exception {
        String hql = "from Bank where userId = ? order by authStatus desc ";
        List<Object> objects = new ArrayList<>();
        objects.add(params.getUserId());

        List<Bank> banks = userDao.getAllObjectsByHql(hql, objects);
        return successMessage(banks);
    }

    @Override
    public String result() throws Exception {
        return successMessage();
    }
}
